﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XHFrame;
using UnityEngine.UI;
using System;

public class GameController : DDOLSingleton<GameController>
{
    #region 模拟切换场景逻辑



    #endregion


    public TextAsset xt;
    private Debuger log = null;

    private void Awake()
    {
        Debuger.LoedConfig(xt.text);
        Debuger.LogFileDir = Application.persistentDataPath + "/pp/";
        Debug.Log(Application.persistentDataPath + "/pp/");
        log = Debuger.GetLogger(typeof(GameController));
        Debuger.EnadleStack = true;

    }

    // Use this for initialization
    void Start()
    {
        ModuleManager.Instance.RegisterModes(typeof(TestOneModule));
        SceneManager.Instance.RegisterAllScene();

        #region MyRegion
        //log.L("1");
        //log.W("2");
        //log.E("3");
        //RegisterModes();
        //float time = System.Environment.TickCount;
        UIManager.Instance.OpenUI(EnumUIType.testOne);
        //#region 测试资源生产
        ////for (int i = 1; i < 3; i++)
        ////{
        ////    GameObject go = null;
        ////    //go = Instantiate(Resources.Load<GameObject>("Prefabs/Cube"));
        ////    //go.transform.position = UnityEngine.Random.insideUnitSphere * 20;

        ////    //go = ResourcesManager.Instance.LoadInstance("Prefabs/Cube") as GameObject;
        ////    //go.transform.position = UnityEngine.Random.insideUnitSphere * 20;

        ////    ResourcesManager.Instance.LoadCoroutineInstance("Prefabs/Cube", (_obj) =>
        ////    {
        ////        go = _obj as GameObject;
        ////        go.transform.position = UnityEngine.Random.insideUnitSphere * 10;
        ////    });

        ////    //ResourcesManager.Instance.LoadAsyncInstance("Prefabs/Cube", (_obj) =>
        ////    //{
        ////    //    go = _obj as GameObject;
        ////    //    go.transform.position = UnityEngine.Random.insideUnitSphere * 20;
        ////    //});
        ////}
        //#endregion
        //StartCoroutine(enumerator());
        ////StartCoroutine(testMessage());
        //Debug.Log("Time:" + (System.Environment.TickCount - time) * 1000);
        #endregion

    }

    //private IEnumerator testMessage()
    //{
    //    while (true)
    //    {
    //        yield return new WaitForSeconds(1.0f);
    //        Message message = new Message("MyMessage", this, "啊啊啊");
    //        message["testMessage"] = "MyMessage!!";
    //        message.Send();
    //    }
    //}



    //public IEnumerator enumerator()
    //{
    //    int gold = 0;
    //    while (true)
    //    {
    //        gold++;
    //        yield return new WaitForSeconds(1.0f);
    //        Message message = new Message(MessageType.Net_MessageTypeOne, this);
    //        message["gold"] = gold;
    //        MessageCenter.Instance.SendMessage(message);
    //        //Message message = new Message("AutoUpdateGold", this);
    //        //message["gold"] = gold;
    //        //message.Send();
    //    }
    //}

}
